package org.gnyxy.controller.front;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.gnyxy.entity.Type;
import org.gnyxy.result.Result;
import org.gnyxy.service.TypeService;
import org.gnyxy.vo.TypeVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("UserTypeController")
@RequestMapping("/front/type")
@Slf4j
@Api(tags = "小程序端-菜品类别")
public class TypeController {

    @Autowired
    private TypeService typeService;
    /**
     * 查看分类
     * @return
     */
    @GetMapping("/getType")
    @ApiOperation("获取所有商品类别")
    @Cacheable(cacheNames = "typeCache", key = "'AllTypes'")
    public Result getType(){
        log.info("获取所有商品类别");
        List<TypeVO> typeVOs = typeService.getType();
        return Result.success(typeVOs);
    }

}
